package com.buybuyyi.stylistcrm.resource.controllers.goods;


import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.buybuyyi.stylistcrm.resource.goods.service.DictionaryService;

import stylistcrm.core.services.goods.dto.DicBrandDTO;
import stylistcrm.core.services.goods.dto.DicClassificationsDTO;
import stylistcrm.core.services.goods.dto.DicMaterialBrandDTO;
import stylistcrm.core.services.goods.dto.DicMaterialCottonDTO;
import stylistcrm.core.services.goods.dto.DicTagsDTO;
import stylistcrm.core.services.goods.dto.GoodsResultDTO;


@Controller
@RequestMapping("/dictionary")
public class DictionaryController {

	@Autowired
	DictionaryService dictionaryService;
	
	@RequestMapping("saveDicBrand")
	@ResponseBody
	public GoodsResultDTO saveDicBrand(DicBrandDTO brandDto){
		GoodsResultDTO goodsResultDTO=new GoodsResultDTO();
		try {
			goodsResultDTO=dictionaryService.saveDicBrand(brandDto);
		} catch (Exception e) {
			goodsResultDTO.setCode("0");
			goodsResultDTO.setMessage("系统异常");
		}
		return goodsResultDTO;
	}
	
	
	//品牌
	@RequestMapping("getDicBrands")
	@ResponseBody
	public List<DicBrandDTO> getDicBrands(){
		List<DicBrandDTO> brandDtos=new ArrayList<DicBrandDTO>();
		try {
			 brandDtos=dictionaryService.getDicBrandList();
		} catch (Exception e) {
			return brandDtos;
		}
		return brandDtos;
	}
	
	@RequestMapping("savaClassicication")
	@ResponseBody
	public GoodsResultDTO saveDicClassicication(DicClassificationsDTO dicClassificationsDTO){
		GoodsResultDTO goodsResultDTO=new GoodsResultDTO();
		try {
			goodsResultDTO=dictionaryService.saveDicClassicication(dicClassificationsDTO);
		} catch (Exception e) {
			goodsResultDTO.setCode("0");
			goodsResultDTO.setMessage("系统异常");
		}
		return goodsResultDTO;
	}
	

	//风格
	@RequestMapping("getClassicications")
	@ResponseBody
	public List<DicClassificationsDTO> getDicClassicication(DicClassificationsDTO dicClassificationsDTO){
		List<DicClassificationsDTO> dicClassificationsDTOs=new ArrayList<DicClassificationsDTO>();
		try {
			dicClassificationsDTOs=dictionaryService.getDicClassicication();
		} catch (Exception e) {
			return dicClassificationsDTOs;
		}
		return dicClassificationsDTOs;
	}
	
	
	//面料品牌
	@RequestMapping("saveDicMaterialBrand")
	@ResponseBody
	public GoodsResultDTO saveDicMaterialBrand(DicMaterialBrandDTO dicMaterialbrandDto){
		GoodsResultDTO goodsResultDTO=new GoodsResultDTO();
		try {
			goodsResultDTO=dictionaryService.saveDicMaterialBrand(dicMaterialbrandDto);
		} catch (Exception e) {
			goodsResultDTO.setCode("0");
			goodsResultDTO.setMessage(e.getMessage());
		}
		return goodsResultDTO;
	}
	

	@RequestMapping("getDicMaterialBrands")
	@ResponseBody
	public List<DicMaterialBrandDTO> getDicMaterialBrands(DicMaterialBrandDTO dicMaterialbrandDto){
		List<DicMaterialBrandDTO> dicMaterialbrandDtos=new ArrayList<DicMaterialBrandDTO>();
		try {
			dicMaterialbrandDtos=dictionaryService.getDicMaterialBrandList();
		} catch (Exception e) {
			return dicMaterialbrandDtos;
		}
		return dicMaterialbrandDtos;
	}
	
	
	
	//材质
	@RequestMapping("saveMaterialCotton")
	@ResponseBody
	public GoodsResultDTO saveMaterialCottonDTO(DicMaterialCottonDTO dicMaterialCottonDto){
		GoodsResultDTO goodsResultDTO=new GoodsResultDTO();
		try {
			goodsResultDTO=dictionaryService.saveMaterialCottonDTO(dicMaterialCottonDto);
		} catch (Exception e) {
			goodsResultDTO.setCode("0");
			goodsResultDTO.setMessage("系统异常");
		}
		return goodsResultDTO;
	}
	
	
	@RequestMapping("getMaterialCottons")
	@ResponseBody
	public List<DicMaterialCottonDTO> getMaterialCotton(){
		List<DicMaterialCottonDTO> dicMaterialCottons=new ArrayList<DicMaterialCottonDTO>();
		try {
			dicMaterialCottons=dictionaryService.getDicMaterialCottonList();
		} catch (Exception e) {
			return dicMaterialCottons;
		}
		return dicMaterialCottons;
	}
	
	//标签
	@RequestMapping("saveGoodsTag")
	@ResponseBody
	public GoodsResultDTO savaGoodsTags(DicTagsDTO goodTage){
		GoodsResultDTO goodsResultDTO=new GoodsResultDTO();
		try {
			goodsResultDTO=dictionaryService.saveDicTags(goodTage);
		} catch (Exception e) {
			goodsResultDTO.setCode("0");
			goodsResultDTO.setMessage("系统异常");
		}
		return goodsResultDTO;
	}
	
	
	@RequestMapping("getGoodsTags")
	@ResponseBody
	public List<DicTagsDTO> getGoodsTages(){
		List<DicTagsDTO> dicTagsDTOs=new ArrayList<DicTagsDTO>();
		try {
			dicTagsDTOs=dictionaryService.getDicTagsList();
		} catch (Exception e) {
			return dicTagsDTOs;
		}
		return dicTagsDTOs;
	}
	
	
	
}
